<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/


Route::group(['namespace' => 'Api'], function () {
    
    Route::get('gettoken','AuthController@token'); // 获取token
    Route::get('qrcode','AuthController@getQrcode'); // 获取二维码
    Route::get('poster/{uid}/{id}','PostController@getPoster'); // 获取海报。
    Route::post('upload','UploadController@uploadFile'); //上传图片接口
        
    Route::group(['middleware' => ['checkauth']], function () {
        
        Route::get('user/posts','UserController@posts'); //  获取用户发布的帖子
        Route::get('getme','UserController@getme'); // 当前用户
        Route::post('asyncuserdata','UserController@asyncuserdata'); // 同步用户数据
        Route::get('posts','PostController@index'); //  获取帖子
        Route::post('posts','PostController@createPost'); // 发表帖子
        Route::get('categories','CategoryController@index'); // 获取分类
        Route::post('updateposts','PostController@updatePost'); // 修改帖子
        Route::get('posts/{id}/comments','PostController@comments'); // 获取帖子的评论
        Route::post('posts/{id}/comments','PostController@newComment'); // 发表评论
        Route::delete('posts/{id}/delete','PostController@del'); // 删除
        Route::get('posts/{id}/like','PostController@like'); // 点赞
        Route::get('posts/{id}/unlike','PostController@unlike'); //取消点赞
        Route::get('posts/{id}','PostController@show'); //  获取帖子详细
        Route::get('posts/{id}/data','PostController@info'); //  获取帖子修改数据
        //
        Route::get('comments/{id}/like','CommentController@like'); // 点赞
        Route::get('comments/{id}/unlike','CommentController@unlike'); //取消点赞
        //
        Route::get('users/{id}/posts','UserController@posts'); // 获取用户的帖子
        Route::get('users/{id}/comments','UserController@comments'); // 获取用户的评论

        // todo 未有评论删除功能
    });
    
});
